Sync Gateway Templates
Gateways
Sync Gateway Templates
Synchronize agent configuration files to the gateway
POST
Sync Gateway Templates
Synchronizes agent templates (TOOLS.md, IDENTITY.md, SOUL.md) from Mission Control to agent workspaces on the gateway. This operation writes or updates configuration files for board agents and optionally the gateway main agent.
When to Use
Required in these scenarios:
Then restart gateway and retry sync.
Authentication
Requires organization admin authentication viaAuthorization: Bearer <token> header.
Path Parameters
Gateway UUID to synchronize
Query Parameters
Include the gateway main agent in the sync operation
Sync only board lead agents (skip worker agents)
Force reset of agent sessions during sync
Generate new authentication tokens for all agentsCritical: Required when:
- First-time gateway setup
- Agents are missing from
openclaw.json - Agent tokens were compromised
Force re-bootstrap of agent provisioning
Overwrite existing template files even if unchanged
Limit sync to agents on a specific board
Response
Gateway UUID that was synchronized
Whether main agent was included in sync
Whether sessions were reset
Number of agents successfully updated
Number of agents skipped (no changes or errors)
Whether the main agent was updated
Template Sync Workflow
For each agent selected for sync:- Read existing token from
TOOLS.md(ifrotate_tokens=false) - Generate new token (if
rotate_tokens=trueor token not found) - Render templates from Jinja2 sources:
BOARD_TOOLS.md.j2→TOOLS.mdBOARD_IDENTITY.md.j2→IDENTITY.md(ifidentity_templateexists)BOARD_SOUL.md.j2→SOUL.md(ifsoul_templateexists)
- Write files to agent workspace via gateway RPC:
agents.files.set() - Update database with new token hash (if rotated)
Template Variables
Templates are rendered with these variables:base_url- Mission Control API URL (fromBASE_URLenv var)auth_token- Agent authentication tokenagent_name- Agent display nameagent_id- Agent UUIDboard_id- Board UUID (for board agents)workspace_root- Gateway workspace root pathworkspace_path- Agent’s specific workspace path
When to Use rotate_tokens=true
Required in these scenarios:
- First-time setup: Initial gateway configuration
- Missing openclaw.json entries: Agents
mc-*were removed from gateway config - Token compromise: Security incident requiring token rotation
- Cannot read TOOLS.md: Gateway returns “file not found” errors
Example Request (Normal Sync)
Example Request (Full Reset)
Example Request (Board-Specific Sync)
Example Response (Success)
Example Response (With Errors)
Common Sync Scenarios
Scenario 1: Regular Template Update
After updating agent templates or configuration:Scenario 2: Initial Gateway Setup
First time configuring a gateway:Scenario 3: Emergency Token Rotation
After security incident:Scenario 4: Sync Single Board
Update only agents on a specific board:Scenario 5: Update Only Lead Agents
Sync configuration for board leads only:Error Recovery
”unable to read AUTH_TOKEN from TOOLS.md”
Cause: Agent entry missing fromopenclaw.json on the gateway.
Solution:
“Gateway RPC call failed”
Causes:- Gateway is offline or unreachable
- Network connectivity issues
- Gateway authentication failed
- Check gateway status:
systemctl status openclaw-gateway - Verify network:
nc -zv gateway-host 18789 - Test gateway auth: Review gateway logs
”Missing scope: operator.read”
Cause: Gateway missingdangerouslyDisableDeviceAuth setting.
Solution: Update ~/.openclaw/openclaw.json:
Best Practices
- Regular Syncs: Run template sync after updating agent configurations
- Token Rotation: Use
rotate_tokens=trueonly when necessary (expensive operation) - Dry Runs: Test sync on a single board first before syncing all boards
- Error Monitoring: Check
errorsarray in response and fix before retrying - Incremental Updates: Use
board_idparameter to limit scope when possible - Overwrite Control: Use
overwrite=false(default) to avoid unnecessary writes
Template Files Generated
TOOLS.md
Contains API credentials and endpoints:IDENTITY.md
Agent role and behavior (ifidentity_template is set):
SOUL.md
Deeper agent instructions (ifsoul_template is set):